import { http } from '../../http'
import { BasePageParam, ResponsePage } from '@/service/api/type'
import {
  DataToday,
  EtwStoreImage, MyStoreInfo,
  SimpleStoreInfo,
  StoreCouponOrderVo,
  StoreCouponVo, StoreWallet, StoreWalletDrawApply, StoreWalletRecord, WithdrawalRange
} from '@/service/api/modules/store/response'
import {
  changeStoreOnlineStatusParams,
  GetStoreOrdersParams,
  StoreWalletDrawApplyParams
} from '@/service/api/modules/store/param'

// 获取店铺基本信息
const getStoreSimpleInfo = (storeId: number | string) => http.get<void, SimpleStoreInfo>(`/activity/coupon/store/info/${storeId}`)

// 获取店铺图片
const getStoreImages = (storeId: number | string) => http.get<void, EtwStoreImage[]>(`/store/image/${storeId}`)

// 添加店铺图片
const addStoreImages = (params: EtwStoreImage) =>  http.post<EtwStoreImage, void>('/store/image', params)

// 删除店铺图片
const deleteStoreImagess = (storeId:number | string,imageId:number | string) => http.delete<EtwStoreImage, void>(`/store/image/${storeId}/image/${imageId}`)

// 修改店铺logo/店铺名
const reviseStoreInfo = (params: SimpleStoreInfo) => http.put<SimpleStoreInfo, void>('/store/', params)

// 商家上下线
const changeStoreOnlineStatus = (params: changeStoreOnlineStatusParams) => http.put<changeStoreOnlineStatusParams, void>('/store/online', params)

// 商家配送状态
const changeStoreDeliveryStatus = (params: changeStoreOnlineStatusParams) => http.put<changeStoreOnlineStatusParams, void>('/store/delivery/status', params)

// 标记订单已出餐
const ordersMade = (couponUserId:string|number ) => http.put<{couponUserId:string|number}, void>(`/store/coupon/user/${couponUserId}/made`)

// 获取店铺订单
const getStoreOrders = (params: GetStoreOrdersParams) => http.get<GetStoreOrdersParams, ResponsePage<StoreCouponOrderVo>>('/store/orders', params)

// 获取我的店铺信息
const getMyStoreInfo = () => http.get<void, MyStoreInfo>('/store/mine')

// 获取店铺优惠券列表
const getStoreCouponList = (params: BasePageParam) => http.get<BasePageParam, ResponsePage<StoreCouponVo>>('/store/coupon/list', params)

// 获取店铺钱包
const getStoreWallet = () => http.get<void, StoreWallet>('/store/wallet')

// 获取店铺提现额度范围
const getStoreWalletLimit = () => http.get<void, WithdrawalRange>('/store/wallet/draw/apply/limit')

// 获取提现申请记录
const getStoreWalletDrawApplyList = (params: BasePageParam) => http.get<BasePageParam, ResponsePage<StoreWalletDrawApply>>('/store/wallet/draw/apply', params)

// 提现申请
const applyStoreWalletDraw = (params: StoreWalletDrawApplyParams) => http.post<StoreWalletDrawApplyParams, void>('/store/wallet/draw/apply', params)

// 获取出入账记录
const getStoreWalletRecordList = (params: BasePageParam) => http.get<BasePageParam, ResponsePage<StoreWalletRecord>>('/store/wallet/record', params)

// 获取待入账记录
const getStoreWalletToBeRecordList = (params: BasePageParam) => http.get<BasePageParam, ResponsePage<StoreWalletRecord>>('/store/wallet/to/be/record', params)

// 获取今日数据
const getTodayData = () => http.get<void, DataToday>('/store/data/today')

export default {
  getStoreSimpleInfo,
  getStoreImages,
  addStoreImages,
  deleteStoreImagess,
  reviseStoreInfo,
  changeStoreOnlineStatus,
  changeStoreDeliveryStatus,
  getStoreOrders,
  getMyStoreInfo,
  getStoreCouponList,
  getStoreWallet,
  getStoreWalletLimit,
  getStoreWalletDrawApplyList,
  applyStoreWalletDraw,
  getStoreWalletRecordList,
  getStoreWalletToBeRecordList,
  getTodayData,
  ordersMade
}
